package com.gosophia.reportData.action;

import java.util.Collections;
import java.util.List;

import net.sf.json.JSONArray;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.dataDictionary.dto.DataValueDTO;
import com.gosophia.dataDictionary.ws.DataDictionaryWebService;

/**
 * 初始化数据上报列表列表
 * 
 * @author zhao_yanfang
 * 
 */
@Controller("initReportDataListAction")
@Scope("prototype")
public class InitReportDataListAction extends BaseSupportAction {

	/**
	 * 报送发起
	 */
	private final static String BSFQ="bsfq";
	/**
	 * 报送办理
	 */
	private final static String BSBL="bsbl";
	
	/**
	 * 报送查询
	 */
	private final static String BSCX="bscx";
	
    @Autowired
    private DataDictionaryWebService dataDictionaryWebService;
    
    private static final Long IMPORTANCE_ENTRYID = 1014L;
    private List<DataValueDTO> importanceList ;
    private String importanceString;
    
    private String fromFlag;
	/**
	 * 请求参数
	 */
	private String parame;
	/**
	 * 初始化列表页面
	 */
	public String _execute() throws Exception {
        //获取重要程度列表
		importanceList = dataDictionaryWebService.findEnabledDataValueByEntryId(IMPORTANCE_ENTRYID);
        if(importanceList!=null){
            Collections.reverse(importanceList);
            importanceString = JSONArray.fromObject(importanceList).toString().replace("\"", "\\\"");
        }
        if("task".equals(fromFlag)){
            return "TASK";
        }else{
            if(parame!=null){
                if(parame.equals(BSCX)){
                    return BSCX;
                }else if(parame.equals(BSBL)){
                    return BSBL;
                }else if(parame.equals(BSFQ)){
                    return BSFQ;
                }
            } 
        }
        return SUCCESS;
	}
	public String getParame() {
		return parame;
	}
	public void setParame(String parame) {
		this.parame = parame;
	}
	public List<DataValueDTO> getImportanceList() {
		return importanceList;
	}
	public void setImportanceList(List<DataValueDTO> importanceList) {
		this.importanceList = importanceList;
	}
	public String getImportanceString() {
		return importanceString;
	}
	public void setImportanceString(String importanceString) {
		this.importanceString = importanceString;
	}
    public String getFromFlag() {
        return fromFlag;
    }
    public void setFromFlag(String fromFlag) {
        this.fromFlag = fromFlag;
    }

}
